#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#define FILE_NAME "log.txt"
int main()
{
    umask(0);
    int fd = open(FILE_NAME,O_CREAT | O_RDWR | O_TRUNC, 0666);
    if(fd == -1)
    {
        perror("file open");
        return 1;
    }
    dup2(fd, 1);
    printf("Hello world\n");
    close(fd);
    return 0;
}
